package com.abocode.aichat.server.channel;

import com.abocode.aichat.server.context.ServerRuntimeContext;
import com.abocode.aichat.server.entity.Entity;
import com.abocode.aichat.server.entity.EntityImpl;
import com.abocode.aichat.utils.UUIDUtils;
import com.abocode.aichat.server.entity.Entity;
import com.abocode.aichat.server.entity.EntityImpl;
import com.abocode.aichat.utils.UUIDUtils;
import io.netty.channel.Channel;

/**
 * Created by franky.
 */
public class ChannelWrapper {

    private Channel channel;

    private String channelId;

    private Entity entity;

    private boolean ready = false;

    private ServerRuntimeContext serverRuntimeContext;

    protected ChannelRegistry channelRegistry;

    protected ChannelState channelState = ChannelState.UNCONNECTED;


    public ChannelWrapper(Channel channel) {
        this.channel = channel;
        this.channelId = UUIDUtils.uuid();
    }

    public boolean isReady() {
        return ready;
    }

    public void setReady(boolean ready) {
        this.ready = ready;
    }

    public Entity getEntity() {
        return entity;
    }

    public void setEntity(EntityImpl entity) {
        this.entity = entity;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public String getChannelId() {
        return channelId;
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public void registerEntity(Entity entity) {
        if (entity == null) {
            throw new RuntimeException("entity is null");
        }
        this.entity = entity;
        this.ready = true;
    }
}
